<?php require('includes/functions.php'); ?>
<!DOCTYPE html>
<html>
	<head>
		<title>Viewing Employee</title>
		<link href="css/style.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<?php 
			$id = isset($_GET['id']) ? trim($_GET['id']):null;
			$employees = getEmployee($id); 
		?>
		<?php if ($employees): ?>
        <div class="pambalot">
            <div class="left-pane">
                <div class="horizontal-table-div">
        		<?php foreach ($employees as $employee): ?>
        		<table cellspacing="0" cellpadding="5" border="1" class="vertical-table">
        			<tr>
        				<th>Employee ID</th>
        				<td><?php echo $employee->employee_id ?></td>
        			</tr>
        			<tr>
        				<th>Name</th>
        				<td><?php echo $employee->name ?></td>
        			</tr>
        			<tr>
        				<th>Address</th>
        				<td><?php echo nl2br($employee->address) ?></td>
        			</tr>
        			<tr>
        				<th>Contact</th>
        				<td><?php echo $employee->contact ?></td>
        			</tr>
        			<tr>
        				<th>Email</th>
        				<td><?php echo $employee->email ?></td>
        			</tr>
        			<tr>
        				<th>Gender</th>
        				<td>
        					<?php echo $employee->gender ?>
        				</td>
        			</tr>
        			<tr>
        				<th>Birthdate</th>
        				<td><?php echo date("F d, Y", strtotime($employee->birthdate)) ?></td>
        			</tr>
        			<tr>
        				<th>Department</th>
        				<td><?php echo $employee->department ?></td>
        			</tr>	
        			<tr>
        				<th>Job</th>
        				<td><?php echo $employee->job ?></td>
        			</tr>
        			<tr>
        				<th>Status</th>
        				<td><?php echo $employee->status ?></td>
        			</tr>
        			<tr>
        				<td colspan="2" align="right">
        					<?php $modifyLink = "edit_employee.php?id=" . $employee->employee_id; ?>
        					<input type="button" value="Modify" onclick="location.href='<?php echo $modifyLink ?>'" />
        				</td>
        			</tr>
        		</table>
                <?php endforeach; ?>
    		<?php else: ?>
    			No employees found.
                <a href="index.php">Go back</a>
    		<?php endif ?>
                </div>
            </div>
            <div class="right-pane">
                <p><input type="button" value="Add Employee" onclick="location.href='add_employee.php'" /></p>
       			<p><input type="button" value="View Logs" onclick="location.href='view_logs.php'" /></p>
            </div>
            <div class="clear"></div>
        </div>
	</body>
</html>